package com.neusoft.databus.policy.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractModel;
import com.neusoft.databus.policy.enums.PolicyExpType;

import lombok.Getter;
import lombok.Setter;

/**
 * 策略表达式
 * 
 * @author naxiang
 */
@Getter
@Setter
@Entity
public class Expression extends AbstractModel {
    /**
     * 
     */
    private static final long serialVersionUID = -2375448080989817470L;
    /**
     * 表达式类型
     */
    @Enumerated(EnumType.STRING)
    @NotNull(message = "表达式类型不能为空")
    @Column(nullable = false)
    private PolicyExpType type;

    /**
     * 表达式
     */
    @NotBlank(message = "表达式不能为空")
    @Length(max = 1023, message = "表达式不能超过{max}位")
    @Column(length = 1023, nullable = false)
    private String expressionInfo;

    /**
     * 连接符
     */
    @Length(max = 255, message = "连接符不能超过{max}位")
    @Column(length = 255)
    private String linkSymbol;

    /**
     * 排序符
     */
    @NotNull(message = "排序符不能为空")
    @Min(value = 0, message = "排序符不能小于{value}")
    @Column(nullable = false)
    private int sequence;

    /**
     * 拓展属性
     */
    @Length(max = 1023, message = "拓展属性不能超过{max}位")
    @Column(length = 1023)
    private String extendProperty;
}
